package jh.com.jhappbf.contract;

import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.ab.activity.AbActivity;
import com.ab.view.titlebar.AbTitleBar;

import androidx.core.content.ContextCompat;
import jh.com.jhappbf.R;
import jh.com.jhappbf.ui.State;

/**
 * @author Administrator
 */
public class PasswordConfirmActivity extends AbActivity {

    private Button mBtn;
    private EditText mTxt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setAbContentView(R.layout.confirm_activity);
        AbTitleBar mAbTitleBar = this.getTitleBar();
        mAbTitleBar.setTitleText("密码确认");
        mAbTitleBar.setLogo(R.drawable.button_selector_back);
        mAbTitleBar.setTitleBarBackgroundColor(ContextCompat.getColor(this, R.color.orange));
        mAbTitleBar.setTitleTextMargin(10, 0, 0, 0);
        mAbTitleBar.setLogoLine(R.mipmap.line);

        mTxt = findViewById(R.id.confirm_user_pwd_edit);
        mBtn = findViewById(R.id.confirm_user_pwd_btn);
        mBtn.setOnClickListener(v -> {
            String pwd = mTxt.getText().toString();
            if (pwd.equals(State.mPwd)) {
                PasswordConfirmActivity.this.setResult(RESULT_OK);
                PasswordConfirmActivity.this.finish();
            } else {
                Toast.makeText(PasswordConfirmActivity.this, "密码错误", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
